<!DOCTYPE html>
<html>

<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>商家审核</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <link rel="stylesheet" href="/plugins/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/plugins/adminLTE/css/AdminLTE.css">
    <link rel="stylesheet" href="/plugins/adminLTE/css/skins/_all-skins.min.css">
    <link rel="stylesheet" href="/css/style.css">
    <script src="/plugins/jQuery/jquery-2.2.3.min.js"></script>
    <script src="/plugins/bootstrap/js/bootstrap.min.js"></script>

</head>

<body class="hold-transition skin-red sidebar-mini">
<!-- .box-body -->
<div class="box box-primary">
    <div class="box-header with-border">
        <h3 class="box-title">商家审核</h3>
    </div>
    <div class="box-body">
        <!-- 数据表格 -->
        <div class="table-box">
            <!--工具栏-->
            <input type="hidden" id="aaaa">
            <div class="box-tools pull-right">
                <div class="has-feedback">
                    公司名称：<input id="name">
                    店铺名称： <input id="nickName">
                    <button class="btn btn-default" onclick="getall()">查询</button>
                </div>
            </div>
            <!--工具栏/-->
            <!--数据列表-->
            <table id="dataList" class="table table-bordered table-striped table-hover dataTable">
                <thead>
                <tr>
                    <!--<th class="" style="padding-right:0px">
                        <input id="selall" type="checkbox" class="icheckbox_square-blue" onclick="reversal()">
                    </th>-->
                    <th class="sorting_asc">商家ID</th>
                    <th class="sorting">公司名称</th>
                    <th class="sorting">店铺名称</th>
                    <th class="sorting">联系人姓名</th>
                    <th class="sorting">公司电话</th>
                    <th class="text-center">操作</th>
                </tr>
                </thead>
                <tbody id="shuju">
                </tbody>
            </table>
            <!--数据列表/-->
            <!--数据列表页面加载-->
            <script type="text/javascript">
                $.ajax({
                    url: "/TbSeller/TbSellershowall",
                    data: {},
                    type: "post",
                    dataType: "json",
                    async: false,
                    success: function (pm) {
                        var TbSeller = pm.data.rows;
                        var TbSellerList = '';
                        $(TbSeller).each(function (i, e) {
                            TbSellerList += '<tr>'
                            // TbSellerList += '<td><input type="checkbox" name="checkbox"></td>'
                            TbSellerList += '<td>' + e.sellerId + '</td>'
                            TbSellerList += '<td>' + e.name + '</td>'
                            TbSellerList += '<td>' + e.nickName + '</td>'
                            TbSellerList += '<td>' + e.linkmanName + '</td>'
                            TbSellerList += '<td>' + e.telephone + '</td>'
                            TbSellerList += '<td className="text-center">'
                            TbSellerList += '<button type="button" onclick="xiangqing(' + "'" + e.sellerId + "'" + ')" className="btn bg-olive btn-xs" data-toggle="modal" data-target="#sellerModal">详情'
                            TbSellerList += '</button>'
                            TbSellerList += '</td>'
                            TbSellerList += '</tr>'
                        })
                        TbSellerList += '<tr><td colspan="6">'
                        TbSellerList += '<input type="button" value="首页" onclick="skip(0)"> '
                        TbSellerList += '<input type="button" value="上一页" onclick="skip(1)"> '
                        TbSellerList += '<span id="pageNum">' + pm.data.pageNum + '</span> / <span id="pages">' + pm.data.pages
                        TbSellerList += '</span> <input type="button" value="下一页" onclick="skip(2)"> '
                        TbSellerList += '<input type="button" value="末页" onclick="skip(3)"> '
                        TbSellerList += '</td></tr>'
                        $("#shuju").html(TbSellerList);
                    },
                    error: function () {
                        alert("系统异常")
                    }
                })

                //换页逻辑
                function skip(pm) {
                    let pageNum = $("#pageNum").text();
                    let pages = $("#pages").text();
                    if (pm == 0) {
                        if (pageNum == 1) {
                            alert("已是首页")
                        } else {
                            $("#pageNum").text(1)
                            getall()
                        }
                    } else if (pm == 1) {
                        if (pageNum == 1) {
                            alert("已是第一页")
                        } else {
                            $("#pageNum").text(pageNum - 1)
                            getall()
                        }
                    } else if (pm == 2) {
                        if (pageNum == pages) {
                            alert("已是最后一页")
                        } else {
                            $("#pageNum").text(parseInt(pageNum) + 1)
                            getall()
                        }
                    } else if (pm == 3) {
                        if (pageNum == pages) {
                            alert("已是末页")
                        } else {
                            $("#pageNum").text(pages)
                            getall()
                        }
                    }
                }

                //加载换页后商品类型模板内容
                function getall() {
                    //加载商品类型模板表内容
                    let pageNum = $("#pageNum").text();
                    let pages = $("#pages").text();
                    let name = $("#name").val();
                    let nickName = $("#nickName").val();
                    $.ajax({
                        url: "/TbSeller/TbSellershowall",
                        data: {pageNum: pageNum, pages: pages, name: name, nickName: nickName},
                        type: "post",
                        dataType: "json",
                        async: false,
                        success: function (pm) {
                            var TbSeller = pm.data.rows;
                            var TbSellerList = '';
                            $(TbSeller).each(function (i, e) {
                                TbSellerList += '<tr>'
                                // TbSellerList += '<td><input type="checkbox" name="checkbox"></td>'
                                TbSellerList += '<td>' + e.sellerId + '</td>'
                                TbSellerList += '<td>' + e.name + '</td>'
                                TbSellerList += '<td>' + e.nickName + '</td>'
                                TbSellerList += '<td>' + e.linkmanName + '</td>'
                                TbSellerList += '<td>' + e.telephone + '</td>'

                                TbSellerList += '<td className="text-center">'
                                TbSellerList += '<button type="button" onclick="xiangqing(' + "'" + e.sellerId + "'" + ')" className="btn bg-olive btn-xs" data-toggle="modal" data-target="#sellerModal">详情'
                                TbSellerList += '</button>'
                                TbSellerList += '</td>'
                                TbSellerList += '</tr>'
                            })
                            TbSellerList += '<tr><td colspan="7">'
                            TbSellerList += '<input type="button" value="首页" onclick="skip(0)"> '
                            TbSellerList += '<input type="button" value="上一页" onclick="skip(1)"> '
                            TbSellerList += '<span id="pageNum">' + pm.data.pageNum + '</span> / <span id="pages">' + pm.data.pages
                            TbSellerList += '</span> <input type="button" value="下一页" onclick="skip(2)"> '
                            TbSellerList += '<input type="button" value="末页" onclick="skip(3)"> '
                            TbSellerList += '</td></tr>'
                            $("#shuju").html(TbSellerList);
                        },
                        error: function () {
                            alert("系统异常")
                        }
                    })
                }

                <!--复选框反转-->
                function reversal() {
                    $("[name=checkbox]").prop("checked", $("#selall").prop("checked"))
                }

            </script>
        </div>
        <!-- 数据表格 /-->


    </div>
    <!-- /.box-body -->


    <!-- 商家详情 -->
    <div class="modal fade" id="sellerModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h3 id="myModalLabel">商家详情</h3>
                </div>
                <div class="modal-body">

                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#home" data-toggle="tab">基本信息</a></li>
                        <li><a href="#linkman" data-toggle="tab">联系人</a></li>
                        <li><a href="#certificate" data-toggle="tab">证件</a></li>
                        <li><a href="#ceo" data-toggle="tab">法定代表人</a></li>
                        <li><a href="#bank" data-toggle="tab">开户行</a></li>
                    </ul>

                    <!-- 选项卡开始 -->
                    <div id="myTabContent" class="tab-content">

                    </div>
                    <!-- 选项卡结束 -->

                </div>
                <div class="modal-footer">
                    <button class="btn btn-success" onclick="shenhe(1)" data-dismiss="modal" aria-hidden="true">审核通过
                    </button>
                    <button class="btn btn-danger" onclick="shenhe(2)" data-dismiss="modal" aria-hidden="true">审核未通过
                    </button>
                    <button class="btn btn-danger" onclick="shenhe(3)" data-dismiss="modal" aria-hidden="true">关闭商家
                    </button>
                    <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">关闭</button>
                </div>

                <!--修改审核状态-->
                <script type="text/javascript">
                    function shenhe(a) {
                        var sellerId = $("#aaaa").val();
                        $.ajax({
                            url: "/TbSeller/updateTbSeller",
                            data: {sellerId: sellerId, status: a},
                            type: "post",
                            dataType: "json",
                            async: false,
                            success: function (pm) {
                                if (pm.code == 3) {
                                    if (a == 1) {
                                        alert("审核通过成功")
                                    }
                                    if (a == 2) {
                                        alert("审核成功未通过")
                                    }
                                    if (a == 3) {
                                        alert("成功关闭商家")
                                    }
                                }
                            },
                            error: function () {
                                alert("系统异常")
                            }
                        })
                    }
                </script>
            </div>
        </div>
    </div>
    <!--详情显示-->
    <script type="text/javascript">
        function xiangqing(sellerId) {
            $("#aaaa").val(sellerId);
            $.ajax({
                url: "/TbSeller/TbSellershowbysellerId",
                data: {sellerId: sellerId},
                type: "post",
                dataType: "json",
                async: false,
                success: function (pm) {
                    var aa = pm.data;
                    var s = '<div class="tab-pane active in" id ="home"><br>'
                    s += '<table class="table table-bordered table-striped" width="800px">'
                    s += '<tr><td>公司名称</td>'
                    s += '<td>' + aa.name + '</td>'
                    s += '</tr><tr>'
                    s += '<td>公司手机</td>'
                    s += '<td>' + aa.mobile + '</td>'
                    s += '</tr><tr>'
                    s += '<td>公司电话</td>'
                    s += '<td>' + aa.telephone + '</td>'
                    s += '</tr><tr>'
                    s += '<td>公司详细地址</td>'
                    s += '<td>' + aa.addressDetail + '</td>'
                    s += '</tr></table></div>'
                    s += '<div class="tab-pane fade" id="linkman"> <br>'
                    s += '<table class="table table-bordered table-striped">'
                    s += '<tr> <td>联系人姓名</td>'
                    s += '<td>' + aa.linkmanName + '</td>'
                    s += '</tr> <tr>'
                    s += '<td>联系人QQ</td>'
                    s += '<td>' + aa.linkmanQq + '</td>'
                    s += '</tr> <tr>'
                    s += '<td>联系人手机</td>'
                    s += '<td>' + aa.linkmanMobile + '</td>'
                    s += '</tr><tr>'
                    s += '<td>联系人E-Mail</td>'
                    s += '<td>' + aa.linkmanEmail + '</td>'
                    s += '</tr></table> </div>'
                    s += '<div class="tab-pane fade" id="certificate"><br>'
                    s += '<table class="table table-bordered table-striped">'
                    s += '<tr> <td>营业执照号</td>'
                    s += '<td>' + aa.licenseNumber + '</td>'
                    s += '</tr> <tr>'
                    s += '<td>税务登记证号</td>'
                    s += '<td>' + aa.taxNumber + '</td>'
                    s += '</tr> <tr>'
                    s += '<td>组织机构代码证号</td>'
                    s += '<td>' + aa.orgNumber + '</td>'
                    s += '</tr></table></div>'
                    s += '<div class="tab-pane fade" id="ceo">'
                    s += '<br> <table class="table table-bordered table-striped">'
                    s += '<tr> <td>法定代表人</td>'
                    s += '<td>' + aa.legalPerson + '</td> </tr> <tr>'
                    s += '<td>法定代表人身份证号</td>'
                    s += '<td>' + aa.legalPersonCardId + '</td>'
                    s += '</tr></table></div>'
                    s += '<div class="tab-pane fade" id="bank"><br>'
                    s += '<table class="table table-bordered table-striped">'
                    s += '<tr> <td>开户行名称</td>'
                    s += '<td>' + aa.bankUser + '</td>'
                    s += '</tr><tr><td>开户行支行</td>'
                    s += '<td>' + aa.bankName + '</td> </tr> <tr>'
                    s += '<td>银行账号</td>'
                    s += '<td>没有资源</td>'
                    s += '</tr> </table> </div>'

                    $("#myTabContent").html(s);
                },
                error: function () {
                    alert("系统异常")
                }
            })
        }
    </script>
</div>
</body>

</html>